<template>
  <div class="user-page">
    <h1>用户信息</h1>
    <div>
      <p>当前余额: {{ balance.toFixed(2) }}元</p>
    </div>
  </div>
</template>

<script>
import { getUserInfo } from "@/api/user";

export default {
  name: "UserPage",
  data() {
    return {
      balance: 0,
    };
  },
  mounted() {
    this.fetchUserInfo();
  },

  methods: {
    async fetchUserInfo() {
      try {
        const response = await getUserInfo();
        this.balance = response.data;
        console.log("余额:", this.balance);
      } catch (error) {
        console.error("获取用户信息失败:", error);
      }
    },
  },
};
</script>

<style scoped>
.user-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}
</style>
